<?php

class feedback_Model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }
    /**
     * @param feedback $feedback
     * @throws DatabaseException
     * @return feedback
     */
    public static function add($feedback)
    {
        /** @var CI $CI */
        $CI =& get_instance();

        $result = $CI->db->insert('feedback', self::getModelByfeedback($feedback));
        if ($result)
            return true;
        else
            throw new DatabaseException('插入数据失败');
    }

    /**
     * @param feedback $thatfeedback
     * @return array
     */
    public static function getModelByfeedback($thatfeedback)
    {
        return array(
            'feedback_content'                => $thatfeedback->getContent(),
            'release_time'           => $thatfeedback->getReleaseTime(),
        );
    }
}